// 导入 Joi 来定义验证规则
const Joi = require("joi");

const userInfoSchema = {
  // 2.1 校验 req.body 中的数据
  body: {
    nickname: Joi.string().required(),
    email: Joi.string().required(),
  },
};

let password = Joi.string()
  .pattern(/^[\S]{6,15}$/)
  .required();
const updatePwdSchema = {
  body: {
    oldPwd: password,
    newPwd: Joi.not(Joi.ref("oldPwd")).concat(password),
  },
};

const update_avatar_schema = {
  body: {
    avatar: Joi.string().dataUri().required(),
  },
};

module.exports = { userInfoSchema, updatePwdSchema, update_avatar_schema };
